<?php

use Faker\Factory as Faker;
use App\Models\FreightArea;
use App\Repositories\FreightAreaRepository;

trait MakeFreightAreaTrait
{
    /**
     * Create fake instance of FreightArea and save it in database
     *
     * @param array $freightAreaFields
     * @return FreightArea
     */
    public function makeFreightArea($freightAreaFields = [])
    {
        /** @var FreightAreaRepository $freightAreaRepo */
        $freightAreaRepo = App::make(FreightAreaRepository::class);
        $theme = $this->fakeFreightAreaData($freightAreaFields);
        return $freightAreaRepo->create($theme);
    }

    /**
     * Get fake instance of FreightArea
     *
     * @param array $freightAreaFields
     * @return FreightArea
     */
    public function fakeFreightArea($freightAreaFields = [])
    {
        return new FreightArea($this->fakeFreightAreaData($freightAreaFields));
    }

    /**
     * Get fake data of FreightArea
     *
     * @param array $postFields
     * @return array
     */
    public function fakeFreightAreaData($freightAreaFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'first_number' => $fake->word,
            'first_price' => $fake->word,
            'continue_number' => $fake->word,
            'continue_price' => $fake->word,
            'shop_id' => $fake->randomDigitNotNull,
            'status' => $fake->randomDigitNotNull,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $freightAreaFields);
    }
}
